{% macro flash_messages() %}
  {% for type, flashMessages in app.session.flashbag.all() %}
    {% for flashMessage in flashMessages %}
      <div class="alert alert-{{ type }}">{{ flashMessage|raw }}</div>
    {% endfor %}
  {% endfor %}
{% endmacro %}

{% macro paginator(paginator, class) %}
  {% if paginator.lastPage > 1 %}
    <nav>
      <ul class="pagination">
        {% if paginator.currentPage != paginator.firstPage %}
          <li><a  href="{{ paginator.getPageUrl(paginator.firstPage) }}">首页</a></li>
          <li><a  href="{{ paginator.getPageUrl(paginator.previousPage) }}"><i class="iconfont icon-chevronleft"></i></a></li>
        {% endif %}
        {% for page in paginator.pages %}
          <li {% if page == paginator.currentPage %}class="active"{% endif %}><a href="{{ paginator.getPageUrl(page) }}">{{ page }}</a></li>
        {% endfor %}

        {% if paginator.currentPage != paginator.lastPage %}
          <li><a  href="{{ paginator.getPageUrl(paginator.nextPage) }}"><i class="iconfont icon-chevronright"></i></a></li>
          <li><a  href="{{ paginator.getPageUrl(paginator.getLastPage()) }}">尾页</a></li>
        {% endif %}
      </ul>
    </nav>
  {% endif %}
{% endmacro %}
